<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Byte Arrays</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-data-types.html" title="GLib Data Types">
<link rel="prev" href="glib-Pointer-Arrays.html" title="Pointer Arrays">
<link rel="next" href="glib-Balanced-Binary-Trees.html" title="Balanced Binary Trees">
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="glib.html" title="GLib Overview">
<link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
<link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
<link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
<link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
<link rel="chapter" href="tools.html" title="GLib Tools">
<link rel="index" href="ix01.html" title="Index">
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
<link rel="index" href="ix09.html" title="Index of new symbols in 2.14">
<link rel="index" href="ix10.html" title="Index of new symbols in 2.16">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-Pointer-Arrays.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-data-types.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-Balanced-Binary-Trees.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id3382409" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id3382778" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="glib-Byte-Arrays"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id3382409"></a><span class="refentrytitle">Byte Arrays</span>
</h2>
<p>Byte Arrays &#8212; arrays of bytes, which grow automatically as elements are added</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">

#include &lt;glib.h&gt;


                    <a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>;
<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         <a class="link" href="glib-Byte-Arrays.html#g-byte-array-new">g_byte_array_new</a>                    (void);
<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         <a class="link" href="glib-Byte-Arrays.html#g-byte-array-sized-new">g_byte_array_sized_new</a>              (<a class="link" href="glib-Basic-Types.html#guint">guint</a> reserved_size);
<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         <a class="link" href="glib-Byte-Arrays.html#g-byte-array-append">g_byte_array_append</a>                 (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         const <a class="link" href="glib-Basic-Types.html#guint8">guint8</a> *data,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> len);
<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         <a class="link" href="glib-Byte-Arrays.html#g-byte-array-prepend">g_byte_array_prepend</a>                (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         const <a class="link" href="glib-Basic-Types.html#guint8">guint8</a> *data,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> len);
<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         <a class="link" href="glib-Byte-Arrays.html#g-byte-array-remove-index">g_byte_array_remove_index</a>           (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> index_);
<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         <a class="link" href="glib-Byte-Arrays.html#g-byte-array-remove-index-fast">g_byte_array_remove_index_fast</a>      (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> index_);
<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         <a class="link" href="glib-Byte-Arrays.html#g-byte-array-remove-range">g_byte_array_remove_range</a>           (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> index_,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> length);
void                <a class="link" href="glib-Byte-Arrays.html#g-byte-array-sort">g_byte_array_sort</a>                   (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> compare_func);
void                <a class="link" href="glib-Byte-Arrays.html#g-byte-array-sort-with-data">g_byte_array_sort_with_data</a>         (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> compare_func,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);
<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         <a class="link" href="glib-Byte-Arrays.html#g-byte-array-set-size">g_byte_array_set_size</a>               (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> length);
<a class="link" href="glib-Basic-Types.html#guint8">guint8</a>*             <a class="link" href="glib-Byte-Arrays.html#g-byte-array-free">g_byte_array_free</a>                   (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> free_segment);
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id3382778"></a><h2>Description</h2>
<p>
<a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a> is based on <a class="link" href="glib-Arrays.html#GArray"><span class="type">GArray</span></a>, to provide arrays of bytes which grow
automatically as elements are added.
</p>
<p>
To create a new <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a> use <a class="link" href="glib-Byte-Arrays.html#g-byte-array-new"><code class="function">g_byte_array_new()</code></a>.
</p>
<p>
To add elements to a <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>, use <a class="link" href="glib-Byte-Arrays.html#g-byte-array-append"><code class="function">g_byte_array_append()</code></a>, and
<a class="link" href="glib-Byte-Arrays.html#g-byte-array-prepend"><code class="function">g_byte_array_prepend()</code></a>.
</p>
<p>
To set the size of a <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>, use <a class="link" href="glib-Byte-Arrays.html#g-byte-array-set-size"><code class="function">g_byte_array_set_size()</code></a>.
</p>
<p>
To free a <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>, use <a class="link" href="glib-Byte-Arrays.html#g-byte-array-free"><code class="function">g_byte_array_free()</code></a>.
</p>
<div class="example">
<a name="id3382908"></a><p class="title"><b>Example&#160;22.&#160;Using a <span class="structname">GByteArray</span></b></p>
<div class="example-contents"><pre class="programlisting">
  GByteArray *gbarray;
  gint i;

  gbarray = g_byte_array_new ();
  for (i = 0; i &lt; 10000; i++)
    g_byte_array_append (gbarray, (guint8*) "abcd", 4);

  for (i = 0; i &lt; 10000; i++)
    {
      g_assert (gbarray-&gt;data[4*i] == 'a');
      g_assert (gbarray-&gt;data[4*i+1] == 'b');
      g_assert (gbarray-&gt;data[4*i+2] == 'c');
      g_assert (gbarray-&gt;data[4*i+3] == 'd');
    }

  g_byte_array_free (gbarray, TRUE);
</pre></div>
</div>
<br class="example-break">
</div>
<div class="refsect1" lang="en">
<a name="id3382944"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id3382954"></a><h3>
<a name="GByteArray"></a>GByteArray</h3>
<a class="indexterm" name="id3382966"></a><pre class="programlisting">typedef struct {
  guint8 *data;
  guint	  len;
} GByteArray;
</pre>
<p>
The <span class="structname">GByteArray</span> struct allows access to the public fields of a <span class="structname">GByteArray</span>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><a class="link" href="glib-Basic-Types.html#guint8">guint8</a>&#160;*<em class="structfield"><code>data</code></em>;</span></p></td>
<td>a pointer to the element data. The data may be moved as elements are
added to the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><a class="link" href="glib-Basic-Types.html#guint">guint</a>&#160;<em class="structfield"><code>len</code></em>;</span></p></td>
<td>the number of elements in the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.

</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3383052"></a><h3>
<a name="g-byte-array-new"></a>g_byte_array_new ()</h3>
<a class="indexterm" name="id3383064"></a><pre class="programlisting"><a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         g_byte_array_new                    (void);</pre>
<p>
Creates a new <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>the new <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.


</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3383117"></a><h3>
<a name="g-byte-array-sized-new"></a>g_byte_array_sized_new ()</h3>
<a class="indexterm" name="id3383130"></a><pre class="programlisting"><a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         g_byte_array_sized_new              (<a class="link" href="glib-Basic-Types.html#guint">guint</a> reserved_size);</pre>
<p>
Creates a new <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a> with <em class="parameter"><code>reserved_size</code></em> bytes preallocated. This
avoids frequent reallocation, if you are going to add many bytes to
the array. Note however that the size of the array is still 0.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reserved_size</code></em>&#160;:</span></p></td>
<td>number of bytes preallocated.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>the new <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3383212"></a><h3>
<a name="g-byte-array-append"></a>g_byte_array_append ()</h3>
<a class="indexterm" name="id3383226"></a><pre class="programlisting"><a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         g_byte_array_append                 (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         const <a class="link" href="glib-Basic-Types.html#guint8">guint8</a> *data,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> len);</pre>
<p>
Adds the given bytes to the end of the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
The array will grow in size automatically if necessary.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em>&#160;:</span></p></td>
<td>a <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></p></td>
<td>the byte data to be added.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>len</code></em>&#160;:</span></p></td>
<td>the number of bytes to add.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3383351"></a><h3>
<a name="g-byte-array-prepend"></a>g_byte_array_prepend ()</h3>
<a class="indexterm" name="id3383364"></a><pre class="programlisting"><a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         g_byte_array_prepend                (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         const <a class="link" href="glib-Basic-Types.html#guint8">guint8</a> *data,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> len);</pre>
<p>
Adds the given data to the start of the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
The array will grow in size automatically if necessary.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em>&#160;:</span></p></td>
<td>a <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></p></td>
<td>the byte data to be added.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>len</code></em>&#160;:</span></p></td>
<td>the number of bytes to add.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3383489"></a><h3>
<a name="g-byte-array-remove-index"></a>g_byte_array_remove_index ()</h3>
<a class="indexterm" name="id3383503"></a><pre class="programlisting"><a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         g_byte_array_remove_index           (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> index_);</pre>
<p>
Removes the byte at the given index from a <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
The following bytes are moved down one place.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em>&#160;:</span></p></td>
<td>a <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index_</code></em>&#160;:</span></p></td>
<td>the index of the byte to remove.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3383607"></a><h3>
<a name="g-byte-array-remove-index-fast"></a>g_byte_array_remove_index_fast ()</h3>
<a class="indexterm" name="id3383620"></a><pre class="programlisting"><a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         g_byte_array_remove_index_fast      (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> index_);</pre>
<p>
Removes the byte at the given index from a <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
The last element in the array is used to fill in the space, so this function
does not preserve the order of the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>. But it is faster than
<a class="link" href="glib-Byte-Arrays.html#g-byte-array-remove-index"><code class="function">g_byte_array_remove_index()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em>&#160;:</span></p></td>
<td>a <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index_</code></em>&#160;:</span></p></td>
<td>the index of the byte to remove.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3383744"></a><h3>
<a name="g-byte-array-remove-range"></a>g_byte_array_remove_range ()</h3>
<a class="indexterm" name="id3383760"></a><pre class="programlisting"><a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         g_byte_array_remove_range           (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> index_,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> length);</pre>
<p>
Removes the given number of bytes starting at the given index from a
<a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.  The following elements are moved to close the gap.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em>&#160;:</span></p></td>
<td>a <em class="parameter"><code>GByteArray</code></em>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index_</code></em>&#160;:</span></p></td>
<td>the index of the first byte to remove.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>length</code></em>&#160;:</span></p></td>
<td>the number of bytes to remove.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4


</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3383891"></a><h3>
<a name="g-byte-array-sort"></a>g_byte_array_sort ()</h3>
<a class="indexterm" name="id3383904"></a><pre class="programlisting">void                g_byte_array_sort                   (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> compare_func);</pre>
<p>
Sorts a byte array, using <em class="parameter"><code>compare_func</code></em> which should be a <code class="function">qsort()</code>-style
comparison function (returns less than zero for first arg is less than second 
arg, zero for equal, greater than zero if first arg is greater than second 
arg).
</p>
<p>
If two array elements compare equal, their order in the sorted array is
undefined.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em>&#160;:</span></p></td>
<td>a <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>compare_func</code></em>&#160;:</span></p></td>
<td>comparison function.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3384004"></a><h3>
<a name="g-byte-array-sort-with-data"></a>g_byte_array_sort_with_data ()</h3>
<a class="indexterm" name="id3384018"></a><pre class="programlisting">void                g_byte_array_sort_with_data         (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> compare_func,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre>
<p>
Like <a class="link" href="glib-Byte-Arrays.html#g-byte-array-sort"><code class="function">g_byte_array_sort()</code></a>, but the comparison function takes an extra user data
argument.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em>&#160;:</span></p></td>
<td>a <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>compare_func</code></em>&#160;:</span></p></td>
<td>comparison function.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></p></td>
<td>data to pass to <em class="parameter"><code>compare_func</code></em>.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3384134"></a><h3>
<a name="g-byte-array-set-size"></a>g_byte_array_set_size ()</h3>
<a class="indexterm" name="id3384147"></a><pre class="programlisting"><a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a>*         g_byte_array_set_size               (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> length);</pre>
<p>
Sets the size of the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>, expanding it if necessary.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em>&#160;:</span></p></td>
<td>a <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>length</code></em>&#160;:</span></p></td>
<td>the new size of the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3384258"></a><h3>
<a name="g-byte-array-free"></a>g_byte_array_free ()</h3>
<a class="indexterm" name="id3384271"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint8">guint8</a>*             g_byte_array_free                   (<a class="link" href="glib-Byte-Arrays.html#GByteArray">GByteArray</a> *array,
                                                         <a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> free_segment);</pre>
<p>
Frees the memory allocated by the <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
If <em class="parameter"><code>free_segment</code></em> is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> it frees the actual byte data.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em>&#160;:</span></p></td>
<td>a <a class="link" href="glib-Byte-Arrays.html#GByteArray"><span class="type">GByteArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>free_segment</code></em>&#160;:</span></p></td>
<td>if <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> the actual byte data is freed as well.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>the element data if <em class="parameter"><code>free_segment</code></em> is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>, otherwise <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>


</td>
</tr>
</tbody>
</table></div>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id3384421"></a><div class="refsect2" lang="en"><a name="id3384422"></a></div>
<hr>
<div class="refsect2" lang="en"><a name="id3384423"></a></div>
</div>
</div>
</body>
</html>
